<?php if (!defined('HKCMS_VERSION')) exit(); ?>
{hkcms:admintemplate file="common/Head"}
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
    {hkcms:admintemplate file="common/Nav"}
    <form method="post" class="J_ajaxForm" action="{:url('template/Theme/setting')}">
        {if (!empty($data))}

            {foreach name="data" item="var" key="f_key"}

                {if (!empty($var['data']))}
                    <div class="h_a"><input type="text" class="text input" name="config[{$f_key}][title]" value="{$var['title']}"></div>
                    <div class="table_full">
                        <table width="100%">
                            <col class="th" />
                            <col width="500" />
                            <col />
                            {foreach name="var['data']" item="vo" key="o_key"}
                            {switch name="vo.type"}
                            {case value="text"}
                            <tr>
                                <th>{$vo.title}</th>
                                <td>
                                    <div class="controls">
                                        <input type="text" name="config[{$f_key}][{$o_key}][value]" class="text input" value="{$vo.value}" style="{$vo.style|default=''}">
                                    </div>
                                </td>
                                <td><div class="fun_tips">{$vo.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="radio"}
                            <tr>
                                <th>{$vo.title}</th>
                                <td>
                                    {foreach name="vo.options" item="opt" key="opt_k"}
                                    <label class="radio"> <input type="radio" name="config[{$f_key}][{$o_key}][value]" value="{$opt_k}" {eq name="vo.value" value="$opt_k"} checked{/eq}>{$opt} </label>
                                    {/foreach}
                                </td>
                                <td><div class="fun_tips">{$vo.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="checkbox"}
                            <tr>
                                <th>{$vo.title}</th>
                                <td>
                                    {foreach name="vo.options" item="opt" key="opt_k"}
                                    <label class="checkbox"> <input type="checkbox" name="config[{$f_key}][{$o_key}][value][]" value="{$opt_k}" {if condition=" is_array($vo['value']) && in_array($opt_k,$vo['value']) "} checked{/if}>{$opt} </label>
                                    {/foreach}
                                </td>
                                <td><div class="fun_tips">{$vo.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="select"}
                            <tr>
                                <th>{$vo.title}</th>
                                    {if (!empty($vo['source']))}
                                 <td>
                                     {php}echo file_get_contents(url($vo['source'],['item'=>$vo['value'],'name'=>'config['.$f_key.']['.$o_key.'][value]'],'',true));{/php}
                                 </td>
                                 {else /}
                                 <td>
                                     <select name="config[{$f_key}][{$o_key}][value]" style="{$vo.style|default=''}">
                                         {foreach name="vo.options" item="opt" key="opt_k"}
                                         <option value="{$opt_k}" {eq name="vo.value" value="$opt_k"} selected{/eq}>{$opt}</option>
                                         {/foreach}
                                     </select>
                                 </td>
                                 {/if}
                                <td><div class="fun_tips">{$vo.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="textarea"}
                            <tr>
                                <th>{$vo.title}</th>
                                <td>
                                    <label class="textarea">
                                        <textarea name="config[{$f_key}][{$o_key}][value]" style="{$vo.style|default=''}">{$vo.value}</textarea>
                                    </label>
                                </td>
                                <td><div class="fun_tips">{$vo.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="file"}
                            <tr>
                                <th>{$vo.title}</th>
                                <td>
                                    <?php echo \libs\util\Form::upfiles("config[".$f_key."][".$o_key."][value]",$o_key,$vo['value'],request()->module(),'',50,'input','',$vo['alowexts']); ?>
                                </td>
                                <td><div class="fun_tips">{$vo.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="editor"}
                            <tr>
                                <th>{$vo.title}</th>
                                <td>
                                    <script type="text/plain" id="{$o_key}" name="config[$f_key][{$o_key}][value]">{$vo.value}</script>
                                    <?php echo \libs\util\Form::editor($o_key,$vo['toolbar'],request()->module()); ?>
                                </td>
                                <td><div class="fun_tips">{$vo.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {/switch}
                            {/foreach}
                        </table>
                    </div>
                {else /}
                    <div class="table_full">
                        <div class="h_a"></div>
                        <table width="100%">
                            <col class="th" />
                            <col width="500" />
                            <col />
                            {switch name="var.type"}
                            {case value="text"}
                            <tr>
                                <th>{$var.title}</th>
                                <td>
                                    <div class="controls">
                                        <input type="text" name="config[{$f_key}][value]" class="text input" value="{$var.value}" style="{$var.style|default=''}">
                                    </div>
                                </td>
                                <td><div class="fun_tips">{$var.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="radio"}
                            <tr>
                                <th>{$var.title}</th>
                                <td>
                                    {foreach name="var.options" item="opt" key="opt_k"}
                                    <label class="radio"> <input type="radio" name="config[{$f_key}][value]" value="{$opt_k}" {eq name="var.value" value="$opt_k"} checked{/eq}>{$opt} </label>
                                    {/foreach}
                                </td>
                                <td><div class="fun_tips">{$var.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="checkbox"}
                            <tr>
                                <th>{$var.title}</th>
                                <td>
                                    {foreach name="var.options" item="opt" key="opt_k"}
                                    <label class="checkbox"> <input type="checkbox" name="config[{$f_key}][value][]" value="{$opt_k}" {if condition=" is_array($vo['value']) && in_array($opt_k,$vo['value']) "} checked{/if}>{$opt} </label>
                                    {/foreach}
                                </td>
                                <td><div class="fun_tips">{$var.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="select"}
                            <tr>
                                <th>{$var.title}</th>

                                {if (!empty($var['source']))}
                                <td>
                                    {php}echo file_get_contents(url($var['source'],['item'=>$var['value'],'name'=>'config['.$f_key.'][value]'],'',true));{/php}
                                </td>
                                {else /}
                                <td>
                                    <select name="config[{$f_key}][value]" style="{$var.style|default=''}">
                                        {foreach name="var.options" item="opt" key="opt_k"}
                                        <option value="{$opt_k}" {eq name="var.value" value="$opt_k"} selected{/eq}>{$opt}</option>
                                        {/foreach}
                                    </select>
                                </td>
                                {/if}
                                <td><div class="fun_tips">{$var.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="textarea"}
                            <tr>
                                <th>{$var.title}</th>
                                <td>
                                    <label class="textarea">
                                        <textarea name="config[{$f_key}][value]" style="{$var.style|default=''}">{$var.value}</textarea>
                                    </label>
                                </td>
                                <td><div class="fun_tips">{$var.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="file"}
                            <tr>
                                <th>{$var.title}</th>
                                <td>
                                    <?php echo \libs\util\Form::upfiles("config[".$f_key."][value]",$f_key,$var['value'],request()->module(),'',50,'input','',$var['alowexts']); ?>
                                </td>
                                <td><div class="fun_tips">{$var.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {case value="editor"}
                            <tr>
                                <th>{$var.title}</th>
                                <td>
                                    <script type="text/plain" id="{$f_key}" name="config[{$f_key}][value]">{$var.value}</script>
                                    <?php echo \libs\util\Form::editor($f_key,$var['toolbar'],request()->module()); ?>
                                </td>
                                <td><div class="fun_tips">{$var.tips|default=''}</div></td>
                            </tr>
                            {/case}
                            {/switch}
                        </table>
                    </div>
                {/if}
            {/foreach}
        {/if}


        <div class="btn_wrap">
            <div class="btn_wrap_pd">
                <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">提交</button>
            </div>
        </div>
        <input type="hidden" name="id" value="{$id}" />
    </form>
</div>
<script src="{$config_siteurl}statics/js/common.js"></script>
</body>
</html>